pub use sea_orm::entity::prelude::*;

use super::{custom, admin};

#[derive(Debug, Clone, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "user_auth")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    #[sea_orm(type = "String(Some(32))")]
    pub user_name: String,

    #[sea_orm(type = "Char(Some(70))")]
    pub pwd: String,
}

#[derive(Debug, Clone, Copy, EnumIter)]
pub enum Relation {
    Custom,
    Admin
}

impl RelationTrait for Relation {
    fn def(&self) -> RelationDef {
        match self{
            Relation::Custom => Entity::has_one(custom::Entity).into(),
            Relation::Admin => Entity::has_one(admin::Entity).into(),
        }
    }
}

crate::add_relate!{
    custom::Entity => Entity | Relation::Custom,
    admin::Entity => Entity | Relation::Admin
}


impl ActiveModelBehavior for ActiveModel {}
